
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;

using Swaf;
using Swaf.BizObj;
using Swaf.Call;
using Swaf.Container;
using Swaf.Security;

namespace UserLogin
{
	public class RemoteINameAddressSupport : MarshalByRefObject, INameAddressSupport
	{
		protected INameAddressSupport m_local;
		public RemoteINameAddressSupport(INameAddressSupport local)
		{
			m_local = local;
		}

		#region INameAddressSupport Members

		public XmlSerializationSupport SerializationSupport
		{
			get { return m_local.SerializationSupport; }
		}

		public string Xml
		{
			get { return m_local.Xml; }
		}

		public bool containsField(string nameAddress)
		{
			return m_local.containsField(nameAddress);
		}

		public object get(string nameAddress)
		{
			object x = m_local.get(nameAddress);
			if (x is INameAddressSupport)
				return new RemoteINameAddressSupport((INameAddressSupport)x);
			else
				return x;
		}

		public object get(string nameAddress, object oneArg)
		{
			object x = m_local.get(nameAddress, oneArg);
			if (x is INameAddressSupport)
				return new RemoteINameAddressSupport((INameAddressSupport)x);
			else
				return x;
		}

		public object get(string nameAddress, params object[] infoArgs)
		{
			object x = m_local.get(nameAddress, infoArgs);
			if (x is INameAddressSupport)
				return new RemoteINameAddressSupport((INameAddressSupport)x);
			else
				return x;
		}

		public string getXml(string options)
		{
			return m_local.getXml(options);
		}

		public bool isGetOnly
		{
			get { return m_local.isGetOnly; }
		}

		public void put(string nameAddress, object val, object extraInfo)
		{
			m_local.put(nameAddress, val, extraInfo);
		}

		public void put(string nameAddress, object val)
		{
			m_local.put(nameAddress, val);
		}

		#endregion
		public System.Collections.IEnumerator GetEnumerator() { return null; }
	}

	public class RemoteSecurityPrincipal : MarshalByRefObject, ISecurityPrincipal
	{
		protected ISecurityPrincipal m_localPrincipal;

		public RemoteSecurityPrincipal(ISecurityPrincipal localPrincipal)
		{
			m_localPrincipal = localPrincipal;
		}

		#region ISecurityPrincipal Members

		public INameAddressSupport additionalInfo
		{
			get { return new RemoteINameAddressSupport(m_localPrincipal.additionalInfo); }
		}

		public void assert(string resourceName, Privileges minPrivilege)
		{
			m_localPrincipal.assert(resourceName, minPrivilege);
		}

		public Privileges getPrivilege(string resourceName)
		{
			return m_localPrincipal.getPrivilege(resourceName);
		}
		public Privileges getPrivilege(string resourceName, bool x)
		{
			return m_localPrincipal.getPrivilege(resourceName, x);
		}

		public bool hasPrivilege(string resourceName)
		{
			return m_localPrincipal.hasPrivilege(resourceName);
		}

		public string instanceId
		{
			get { return m_localPrincipal.instanceId; }
		}

		public bool isUserInRole(string roleName)
		{
			return m_localPrincipal.isUserInRole(roleName);
		}

		public INameAddressSupport resourceSets
		{
			get { return m_localPrincipal.resourceSets; }
		}

		public INameAddressSupport roles
		{
			get { return m_localPrincipal.roles; }
		}

		public ICall rolesCall
		{
			get { return m_localPrincipal.rolesCall; }
		}

		public string userName
		{
			get { return m_localPrincipal.userName; }
		}

		public bool deepCloneResourceSets
		{
			get
			{
				throw new Exception("The method or operation is not implemented.");
			}
			set
			{
				throw new Exception("The method or operation is not implemented.");
			}
		}

		#endregion

		#region INameAddressSupport Members

		public XmlSerializationSupport SerializationSupport
		{
			get { return m_localPrincipal.SerializationSupport; }
		}

		public string Xml
		{
			get { return m_localPrincipal.Xml; }
		}

		public bool containsField(string nameAddress)
		{
			return m_localPrincipal.containsField(nameAddress);
		}

		public object get(string nameAddress)
		{
			return m_localPrincipal.get(nameAddress);
		}

		public object get(string nameAddress, object oneArg)
		{
			return m_localPrincipal.get(nameAddress, oneArg);
		}

		public object get(string nameAddress, params object[] infoArgs)
		{
			return m_localPrincipal.get(nameAddress, infoArgs);
		}

		public string getXml(string options)
		{
			return m_localPrincipal.getXml(options);
		}

		public bool isGetOnly
		{
			get { return m_localPrincipal.isGetOnly; }
		}

		public void put(string nameAddress, object val, object extraInfo)
		{
			m_localPrincipal.put(nameAddress, val, extraInfo);
		}

		public void put(string nameAddress, object val)
		{
			m_localPrincipal.put(nameAddress, val);
		}

		#endregion
		public System.Collections.IEnumerator GetEnumerator() { return null; }
		
	}
}
